package code.structure.module.user.data
{
	import code.structure.module.configs.data.LevelConfigData;
	import code.untils.CommandNameConst;
	import code.untils.GameConst;
	
	import com.patience.mvc.context.Command;

	/**
	 *用户基础数据 
	 * @author liangqian
	 * 
	 */	
	public class UserBaseData
	{
		private var _levelConfigData:LevelConfigData;
		
		private var _uId:String;
		private var _uLevel:int;
		private var _uExp:int;
		private var _uCoin:int;
		private var _uDiamond:int;
		private var _uEnergy:int;
		private var _uName:String; 
		private var _uManorName:String;
		private var _uMagic:int; 
		
		private var _sendCMD:Function;
		public function UserBaseData(d:Object,sendCMD:Function)
		{
			_sendCMD = sendCMD;
			
			uId = d.id;
			uLevel = d.level;
			uExp = d.exp;
			uCoin = d.coin;
			uDiamond = d.diamond;
			uEnergy = d.energy;
			uName = d.userName;
			uManorName = d.manorname;
			uMagic = d.magic;
		}

		/**
		 * 发送事件
		 * @param	name
		 * @param	param
		 */
		private function sendCommand(name:String, param:int):void {
			var _command:Command = new Command(name);
			_command.data = param;
			_sendCMD(_command);
		}
		
		/**
		 *用户Id 
		 */
		public function get uId():String
		{
			return _uId;
		}

		/**
		 * @private
		 */
		public function set uId(value:String):void
		{
			_uId = value;
		}

		/**
		 *用户等级 
		 */
		public function get uLevel():int
		{
			return _uLevel;
		}

		/**
		 * @private
		 */
		public function set uLevel(value:int):void
		{
			_uLevel = value;
			trace("iLevel==>>>", _uLevel);
			sendCommand(CommandNameConst.COMMAND_UPDATE_LEVEL, _uLevel);
		}

		/**
		 *用户当前经验值 
		 */
		public function get uExp():int
		{
			return _uExp;
		}

		/**
		 * @private
		 */
		public function set uExp(value:int):void
		{
			_uExp = value;
			trace("uExp==>>>", _uExp);
		}

		/**
		 *用户金币值 
		 */
		public function get uCoin():int
		{
			return _uCoin;
		}

		/**
		 * @private
		 */
		public function set uCoin(value:int):void
		{
			_uCoin = value;
			if (_uCoin > GameConst.MAX_COIN) _uCoin = GameConst.MAX_COIN;
			trace("uCoin==>>>", _uCoin);
			sendCommand(CommandNameConst.COMMAND_UPDATE_COIN, _uCoin);
		}

		/**
		 *用户钻石值 
		 */
		public function get uDiamond():int
		{
			return _uDiamond;
		}

		/**
		 * @private
		 */
		public function set uDiamond(value:int):void
		{
			_uDiamond = value;
			trace("uDiamond==>>>", _uDiamond);
		}

		/**
		 *用户能量值 
		 */
		public function get uEnergy():int
		{
			return _uEnergy;
		}

		/**
		 * @private
		 */
		public function set uEnergy(value:int):void
		{
			_uEnergy = value;
			trace("uEnergy==>>>", _uEnergy);
		}

		/**
		 *用户名字 
		 */
		public function get uName():String
		{
			return _uName;
		}

		/**
		 * @private
		 */
		public function set uName(value:String):void
		{
			_uName = value;
		}

		/**
		 *用户庄园名字 
		 */
		public function get uManorName():String
		{
			return _uManorName;
		}

		/**
		 * @private
		 */
		public function set uManorName(value:String):void
		{
			_uManorName = value;
		}

		/**
		 *用户魅力值 
		 */
		public function get uMagic():int
		{
			return _uMagic;
		}

		/**
		 * @private
		 */
		public function set uMagic(value:int):void
		{
			_uMagic = value;
			trace("uMagic==>>>", _uMagic);
		}

		/**
		 *等级静态数据 
		 * @return 
		 * 
		 */		
		public function get levelConfigData():LevelConfigData
		{
			return _levelConfigData;
		}

		public function set levelConfigData(value:LevelConfigData):void
		{
			_levelConfigData = value;
		}
	}
}